<?php if ($this->data):?>
<script>
$(function(){

	$("#button-div input[type=button]").attr('disabled','disabled');
  $(".selBtn").click(function(){
	    if ($("#listTable input:checkbox:checked").length > 0)
	    	  $("#button-div input[type=button]").attr('disabled','');
	    else
	    	  $("#button-div input[type=button]").attr('disabled','disabled');
	});

  // 列印報表
  $("#print-report").click(function(){
       $("#setForm").ajaxFormUnbind();
	    $("#setForm #act").attr('value','print-report');
	    $("#current_semester").attr('value',$("#yearSemester").val());
	    $("#setForm").submit();
  });

  // 列印封面
  $("#print-cover").click(function(){
	  $("#setForm").ajaxFormUnbind();
      $("#setForm #act").attr('value','print-cover');
      $("#current_semester").attr('value',$("#yearSemester").val());
      $("#setForm").submit();
	});

  // 輸入文號
  $("#assign-word").click(function(){
	  $("#setForm").ajaxForm({success: function(data){
		  if (data.error) {
	            var message = '';
	            $.each(data.error,function(i,val){
	                    $("#"+i).addClass('ui-state-error');
	                    $.each(val,function(ii,vv){
	                        message += $("#"+i+"-label label").html()+': '+ vv+ "\n";
	                    });
	            });
	            jAlert(message, '<?php echo $this->translate('checking errors')?>');
	        }
	        else {
	        jAlert('ok','<?php echo $this->translate('set completed')?>');
	        getData();
	        }
		}});
      $("#setForm #act").attr('value','assign-word');
      $("#setForm").submit();
      });

  $("#listTable").tablesorter();
  $("#listTable tbody tr").mouseover(function() {
      $(this).addClass("trover");}).mouseout(function() {
          $(this).removeClass("trover");});


    $("#approve_date").datepicker({dateFormat: 'yy-mm-dd', showButtonPanel: true});
  //getter
    var showButtonPanel = $( ".selector" ).datepicker( "option", "showButtonPanel" );
    //setter
    $( ".selector" ).datepicker( "option", "showButtonPanel", true );



});
</script>
<style>
#listTable{width:100%; margin: 15px auto; text-align: center }
</style>

<form id="setForm" action="<?php echo $this->route('set')?>" method="post" >
<div>
<?php echo $this->form->approve_organ?>
<?php echo $this->form->approve_date?>
<?php echo $this->form->approve_word?>
<?php echo $this->form->approve_number?>
<div id="button-div" style="margin-top:10px">
<input type="button"  id="print-report" value="<?php echo $this->translate('print report')?>"  />
<input type="button"  id="assign-word" value="<?php echo $this->translate('assign word')?>" />
<input type="button"  id="print-cover" value="<?php echo $this->translate('print cover')?>"  />
</div>
</div>
<table id="listTable" class="tablesorter">
<caption>
<span id="curr_yearSemester"></span><?php echo $this->arrayData['study_cond'][$this->moveKind]?> <?php echo $this->translate('records')?>
</caption>
<thead>
<tr>
<th><?php echo $this->translate('choose')?></th>
<th><?php echo $this->translate('student id')?></th>
<th><?php echo $this->translate('student name')?></th>
<th><?php echo $this->translate('date')?></th>
<th><?php echo $this->translate('approve organ')?></th>
<th><?php echo $this->translate('approve date')?></th>
<th><?php echo $this->translate('approve word number')?></th>
</tr>
</thead>
<tbody>
<?php foreach($this->data as $row):?>
<tr>
<td><input class="selBtn" type="checkbox"  name="selSn[]" value="<?php echo $row['sn']?>"/></td>
<td><?php echo $row['student_id']?></td>
<td><?php echo $row['name']?></td>
<td><?php echo $row['date']?></td>
<td><?php echo $row['approve_organ']?></td>
<td><?php echo $row['approve_date']?></td>
<td><?php echo $row['approve_word']?>
<?php if ($row['approve_number']):?>第<?php echo $row['approve_number']?>號<?php else:?> -- <?php endif?>
</td>
</tr>
<?php endforeach?>
</tbody>
</table>
<input type="hidden"  name="act" id="act" />
<input type="hidden"  name="current_semester" id="current_semester" />
</form>
<?php else:?>
<h1><?php echo $this->translate('no data')?></h1>
<?php endif?>